package com.hjxr.sysadmin.zsj.service.impl;

import java.util.Date;
import java.util.List;

import com.hjxr.framework.config.ServerConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hjxr.sysadmin.zsj.mapper.IntroductionMapper;
import com.hjxr.sysadmin.zsj.domain.Introduction;
import com.hjxr.sysadmin.zsj.service.IIntroductionService;

/**
 * 襄阳概况图文Service业务层处理
 *
 * @author hjxr
 * @date 2021-03-17
 */
@Service
public class IntroductionServiceImpl implements IIntroductionService
{
    @Autowired
    private IntroductionMapper introductionMapper;

    @Autowired
    private ServerConfig serverConfig;

    /**
     * 查询襄阳概况图文
     *
     * @param id 襄阳概况图文ID
     * @return 襄阳概况图文
     */
    @Override
    public Introduction selectIntroductionById(Long id)
    {
        Introduction introduction = introductionMapper.selectIntroductionById(id);
        if (introduction != null && introduction.getPhotoaddres() != null) {
            introduction.setRealaddres(serverConfig.getUrl() + introduction.getPhotoaddres());
        }
        return introduction;
    }

    /**
     * 查询襄阳概况图文列表
     *
     * @param introduction 襄阳概况图文
     * @return 襄阳概况图文
     */
    @Override
    public List<Introduction> selectIntroductionList(Introduction introduction)
    {
        List<Introduction> list = introductionMapper.selectIntroductionList(introduction);
        for (Introduction introduction1 : list) {
            if (introduction1 != null && introduction1.getPhotoaddres() != null) {
                introduction1.setRealaddres(serverConfig.getUrl() + introduction1.getPhotoaddres());
            }
        }
        return list;
    }

    /**
     * 新增襄阳概况图文
     *
     * @param introduction 襄阳概况图文
     * @return 结果
     */
    @Override
    public int insertIntroduction(Introduction introduction)
    {
        introduction.setModifiedTime(new Date());
        return introductionMapper.insertIntroduction(introduction);
    }

    /**
     * 修改襄阳概况图文
     *
     * @param introduction 襄阳概况图文
     * @return 结果
     */
    @Override
    public int updateIntroduction(Introduction introduction)
    {
        introduction.setModifiedTime(new Date());
        return introductionMapper.updateIntroduction(introduction);
    }

    /**
     * 批量删除襄阳概况图文
     *
     * @param ids 需要删除的襄阳概况图文ID
     * @return 结果
     */
    @Override
    public int deleteIntroductionByIds(Long[] ids)
    {
        return introductionMapper.deleteIntroductionByIds(ids);
    }

    /**
     * 删除襄阳概况图文信息
     *
     * @param id 襄阳概况图文ID
     * @return 结果
     */
    @Override
    public int deleteIntroductionById(Long id)
    {
        return introductionMapper.deleteIntroductionById(id);
    }
}
